import Vue from "vue"
import VueRouter from "vue-router"
import IndexPage from "@/pages//index.vue"

import About from "@/pages/haverouter/About.vue"
import News from "@/pages/haverouter/News.vue"
Vue.use(VueRouter)
const routes = [{
    path: '/',
    name: "IndexPage",
    component: IndexPage
  },
  {
    path: '/about',
    name: "About",
    component: About
  },
  {
    path: '/news',
    name: "News",
    component: News
  }
]
let router = new VueRouter({
  mode: "history",
  routes
});
//全局导航守卫
router.beforeEach((to, from, next) => {
  // if (to.name == "About") {
  //   next("/About")
  // } else {
  //   next()
  // }
  next()
})
export function createRouter() {
  return router;
}
